from sqlalchemy import Column, Integer, String, Text, DateTime, func
from sqlalchemy.orm import relationship

from database import Base  # 你已有的 declarative_base 实例


class TestProject(Base):
    __tablename__ = "test_projects"
    __table_args__ = {'comment': '测试项目表'}

    id = Column(Integer, primary_key=True, index=True, comment="项目ID")
    name = Column(String(100), unique=True, nullable=False, comment="项目名称")
    description = Column(Text, nullable=True, comment="项目描述")
    owner = Column(String(50), nullable=False, comment="项目负责人")
    created_at = Column(DateTime, default=func.now(), comment="创建时间")

    versions = relationship("TestVersion", back_populates="project", cascade="all, delete-orphan")
    test_plans = relationship("TestPlan", back_populates="project", cascade="all, delete-orphan")
    test_cases = relationship("TestCase", back_populates="project", cascade="all, delete-orphan")
